<?php
$ROOT = "../../../";
require_once ($ROOT . 'config/config.php');

class RegistryIndex{	
	private $db;
	private $post;
	private $smarty;
	
	function __construct($db, $post, $smarty){
		$this -> db 	= $db;
		$this -> post 	= $post;
		$this -> smarty = $smarty;
	}
	
	
	function insert(){
		$name = $this -> post['name'];
		$email = $this -> post['email'];
		$username = $this -> post['username'];
		$password = $this -> post['password'];
		
		$user = new User("",$name, $email, '', $username, $password, 2, '','');
	
		$result = $user -> insert($this -> db,$user);
		echo $result;
	}
	
	function display(){					
		$this -> smarty ->display('../templates/registry/index.tpl');
	}
	
	function main($db,$smarty,$post){
		$method = $post['method'];
		$index = new RegistryIndex($db,$post,$smarty);
		
		switch ($method){
			case 'insert':
				$index -> insert();		
			
			default:
				$index -> display();
		}
	}
}

RegistryIndex::main($db,$smarty,$_POST);
?>